/******FIGURE A.IV: EFFECTS BY DECEASED WEAPON (WITHOUT POPULATION CONTROLS)***********/


/*******RUN ANALYSIS**********/
use ../data/main.dta, clear
keep if sample_main

foreach x in armed unarmed {
foreach y in reg vote {
	sum `y' if tau==-1 & sample_`x'
	local m = round(r(mean), .01)
	eventdd `y' all if sample_`x', timevar(tau) ///
	absorb(cb CBG#elec_id) hdfe tolerance(0.0001) cluster(CBG) ///
	ci(rarea) ci_op(fcolor(gs10%30))
	parmest, label saving (../estimates/figA4_`y'_`x'_nopop, replace) idstr(`y'_`x')
	outreg2 using ../output/table_event.xls, append stats(coef se) ctitle(`y') dec(3) alpha(.01, .05, .10) addtext(killings, `x', mean, `m') symbol(***, **, *) excel side

}
}

/*******CREATE FIGURES*********/

local color1 = "navy"
local color2 = "maroon*0.65"
local symbol1 = "circle"
local symbol2 = "diamond"
local tsize = "large"
local labsize = "medlarge"
local titlesize = "vlarge"

clear
foreach x in unarmed armed {
foreach y in reg vote {
    append using ../estimates/figA4_`y'_`x'_nopop
}
}

local lower = -40
local upper = 40
local lower1 = `lower'-2
local upper1 = `upper'+2
local increment = 10

gen time = real(substr(parm, -1, 1))
replace time = time*-1 if strpos(parm, "lag")==0

drop if time==.

expand 2 if time==-2, gen(omit)
replace time = -1 if omit
replace estimate = 0 if omit
replace min95 = 0 if omit
replace max95 = 0 if omit

gen reg = strpos(idstr, "reg")!=0

replace time = time -.15 if reg==1
replace time = time + .15 if reg==0


gen type = "unarmed" if strpos(idstr, "unarmed")!=0
replace type = "armed" if type==""

foreach t in unarmed armed {

graph twoway (scatter estimate time if reg, mcolor(`color1') msymbol(`symbol1')) (rcap min95 max95 time if reg, lcolor(`color1')) (scatter estimate time if !reg, mcolor(`color2') msymbol(`symbol2')) (rcap min95 max95 time if !reg, lcolor(`color2')) if type=="`t'", ///
	xline(-.5, lcolor(red)) yline(0, lcolor(gs5)) ///
	ylabel(`lower'(`increment')`upper', grid labsize(`labsize')) yscale(range(`lower1' `upper1')) ///
	xlabel(-4(1)3) xscale(range(-4 3)) ///
	ytitle("Counts", size(`tsize')) ///
	xtitle("Elections to Killing", size(`tsize')) ///
	legend(order(1 3) label(1 "Registrations") label(3 "Votes") size(`tsize')) ///
 plotregion(fcolor(white)) graphregion(fcolor(white) lwidth(large) lcolor(white)) bgcolor(white)
	graph export ../output/figA4_`t'_nopop.png, replace
	graph export ../output/figA4_`t'_nopop.eps, replace

}
